/*************************************************************************
*filename: lwip_api.h
*description: support api to config or set lwip sub system, or get infomation from lwip sub system
*history:
*-------2018-11-02, change from lwip_stats.h to lwip_api.h
**************************************************************************/

#ifndef __LWIP_API_PROVIDER_H__
#define __LWIP_API_PROVIDER_H__

#include "opt.h"
#include "arch.h"
//#include "pbuf.h"
//#include "ip_nat.h"
//#include "Dialer_Task.h"

#define LWIP_PLATFORM_DONGLE_MODE      (0)
#define LWIP_PLATFORM_MIFI_MODE        (1)
#define LWIP_PLATFORM_BRIDGE_MODE      (2)
#define LWIP_PLATFORM_DEFINE_END       (3)

#define LWIP_DL_DIRECTION       (0)
#define LWIP_UL_DIRECTION       (1)

#define IP_PROTO_ICMP    1
#define IP_PROTO_IGMP    2
#define IP_PROTO_UDP     17
#define IP_PROTO_UDPLITE 136
#define IP_PROTO_TCP     6
#define IP_PROTO_GRE     47
#define IP_PROTO_ESP     50
#define IP_PROTO_AH      51

/*********************************
* api for control lwip mode
*
* 0:Dongle, 1:MIFI
*********************************/
u8_t lwip_get_mifi_flag(void);
void lwip_manual_set_pmod(u8_t pmod);

/*********************************/
/* api for get lwip traffic stat */
/*********************************/
unsigned long long lwip_get_rx_byte_all(void);
unsigned long long lwip_get_tx_byte_all(void);

/*********************************
* api for control lwip rate
*
* direction: LWIP_DL_DIRECTION (0), LWIP_UL_DIRECTION (1)
* proto: IP_PROTO_TCP = 6, IP_PROTO_UDP = 17
* flag: disable(0) or enalble(1) rate control
* period: rate evaluate period, normal set to 1
* rate: bytes per period, normal set to Bps
*********************************/
void lwip_rate_control_buildup(int direction, int proto, int flag, u8_t period, u32_t max_rate);
u32_t lwip_rate_control_query(int direction, int proto);

/*********************************
* api for control lwip forward
*
* ip flag: enable(0), disable(1)
* eth,usb,wifi flag: enable(1), disable(0)
*********************************/
int lwip_get_ip_forward_flag(void);
void lwip_set_ip_forward_flag(int flag);
int lwip_get_eth_forward_flag(void);
void lwip_set_eth_forward_flag(int flag);
int lwip_get_usb_forward_flag(void);
void lwip_set_usb_forward_flag(int flag);
int lwip_get_wifi_forward_flag(void);
void lwip_set_wifi_forward_flag(int flag);

/*********************************
* api for control pp mode
*
* flag: enable(0), disable(1)
*********************************/
void lwip_set_adjust_pp_flag(int flag);
int lwip_get_adjust_pp_flag(void);

/* index: 0-7, high is faster */
int lwip_manul_adjust_pp(int index);

/*************************************************
* API function for lwip self call define here
*************************************************/
int lwip_get_val_from_flash(char *para);
void lwip_psm_get_wrapper(char *para, char *para_value, int *max_size);
void lwip_psm_set_wrapper(char *para, char *para_value);

#endif
